<?php

class logo_controller extends controller{
    public function __construct(){
        parent::__construct();
    	
    }
	
	public function _empty(){
        $height = gp('h');
        $w = 260;
        $h = 70;
        
        if ($height && $height!=70) {
            $w = round($height*260/70);
            $h = $height;
        }

        $website = $this->yuming_website;

        $sitename = $website['sitename'];
        $url = $website['name'];
        $ico = mb_substr($sitename, 0, 1, 'utf-8');
        
        $im = imagecreatetruecolor($w, $h);//图片大小
        imagealphablending($im,false);
        imagesavealpha($im,true);
        
        $color = imagecolorallocate($im,255,255,255);
        $imbg = imagecreatefrompng(DATA."/font/logo.png");
        imagesavealpha($imbg,true);

        if ($height && $height!=70) {
            imagecopyresampled($im, $imbg , 0, 0, 0, 0, $w ,$h, 260, 70);
        } else {
            $im = $imbg;
        }
        
        //设置颜色
        $sncolor = ImageColorAllocate($im, 51, 51, 51);//文字颜色
        $urlcolor = ImageColorAllocate($im,  102, 102, 102);//网址颜色
        $icocolor = ImageColorAllocate($im,  50, 157, 204);//图标颜色
        $mczit = DATA."/font/webname.ttf";//网站名称字体
        $urlzt = DATA."/font/webname.ttf";//网址字体
        $zit = DATA."/font/webname.ttf";//网址字体
        //输出图片
        $bili = $h/70;
        ImageTTFText($im, floor(22*$bili), 0, 75*$bili, 35*$bili, $sncolor,$mczit,$sitename);//文字设置
        ImageTTFText($im, floor(13*$bili), 0, 75*$bili, 60*$bili, $urlcolor,$urlzt,$url);//网址设置
        ImageTTFText($im, floor(35*$bili), 0, 15*$bili, 52*$bili, $icocolor,$zit,$ico);//ico设置
        
        Header("Content-type: image/png");
        Imagepng($im);
        ImageDestroy($im);
        exit();
	}
}
